package com.game.league.task.audit.adapter;

import android.app.Activity;

import com.game.base.app.base.BaseAdapter;
import com.game.base.app.callback.ItemOnClick;
import com.game.base.glideV4.ImageLoader;
import com.game.base.utils.DecimalUtil;
import com.game.league.R;
import com.game.league.databinding.AdapterTaskAuditBinding;
import com.game.league.task.table.MyTask;

/**
 * Created by Su on 2019/6/12.
 */
public class AuditAdapter extends BaseAdapter<MyTask, AdapterTaskAuditBinding> {

    public AuditAdapter(Activity activity, ItemOnClick itemOnClick) {
        super(activity, itemOnClick);
    }

    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.adapter_task_audit;
    }

    @Override
    protected void onBindItem(AdapterTaskAuditBinding binding, MyTask item, int position) {
        ImageLoader.loadRoundCenterCrop(mActivity, item.getTask().getImage(), binding.ivAppLogo);
        binding.tvStatusContext.setText(item.getStatusText());
        binding.tvAppName.setText(item.getTask().getTitle());
        binding.tvCreateTime.setText(item.getCreatedAt());
        binding.tvReason.setText(item.getReason());

        float price = DecimalUtil.addFloat(item.getPrice(), item.getExtraPrice());
        String coinAdd = " + " + DecimalUtil.getFormatFloat(price);
        if (item.getStatus() == 1) {
            coinAdd = "待入账" + coinAdd;
        } else if (item.getStatus() == 2) {
            coinAdd = "已失效" + coinAdd;
            binding.tvCoinAdd.setTextColor(mActivity.getResources().getColor(R.color.text_gray));
        } else if (item.getStatus() == 3) {
            coinAdd = "已入账" + coinAdd;
        }
        binding.tvCoinAdd.setText(coinAdd);
    }
}
